package com.gykj.sso.util;

import java.util.concurrent.ThreadLocalRandom;

public class RandomUtil {
    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            System.out.println(randomInt(6));
        }
    }



    /**
     * 1 - 9 位随机数
     * @param len
     * @return
     */
    public static String randomInt(int len) {
        if(len == 0) return "0";
        if(len > 9) return "0";


        int start = (int) Math.pow(10, len-1);
        int end = (int) Math.pow(10, len)-1;

        return String.valueOf(ThreadLocalRandom.current().nextInt(start, end));

    }

}
